﻿Imports BE.BE

Namespace DAL
    Public Class DAL_AbogadoEstudio

        Shared Sub altaAbogadoEstudio(pAbogadoEstudio As AbogadoEstudio_BE)
            Try
                pAbogadoEstudio.IdAbogadoEstudio = Helper_DAL.ObtenerProximoId("abogadoestudio")
                Dim strcomm As String = "insert into abogadoestudio (id_abogadoEstudio, id_usuario, dni, fecha_nacimiento) values " & _
                    "(" & pAbogadoEstudio.IdAbogadoEstudio & "," & pAbogadoEstudio.id & "," & pAbogadoEstudio.Dni & ",'" & pAbogadoEstudio.FechaNacimiento & "')"

                Helper_DAL.ExecuteNonQuery(strcomm)
            Catch ex As Exception
                Throw ex
            End Try

        End Sub

        Shared Function listarAbogadoEstudio() As List(Of AbogadoEstudio_BE)
            Dim strcomm As String = "select id_abogadoEstudio, ae.id_usuario, dni, fecha_nacimiento, id_idioma, nombre, apellido, nick, password, bloqueado, intentos_inc, password_reset, borrado from abogadoEstudio ae " & _
                    "inner join usuario u " & _
                    "on ae.id_usuario = u.id_usuario"
            Dim mlista As New List(Of AbogadoEstudio_BE)
            Dim mds As New DataSet


            Try
                mds = Helper_DAL.ExecuteDataset(strcomm)

                If mds.Tables(0).Rows.Count > 0 Then
                    For Each dr As DataRow In mds.Tables(0).Rows
                        Dim mabog As New AbogadoEstudio_BE

                        mabog.IdAbogadoEstudio = dr.Item(0)
                        mabog.id = dr.Item(1)
                        mabog.Dni = dr.Item(2)
                        mabog.FechaNacimiento = dr.Item(3)
                        mabog.ididioma = dr.Item(4)
                        mabog.nombre = dr.Item(5).ToString
                        mabog.apellido = dr.Item(6).ToString
                        mabog.nick = dr.Item(7).ToString
                        mabog.password = dr.Item(8).ToString
                        mabog.bloqueado = dr.Item(9).ToString
                        mabog.intentosfallidos = dr.Item(10)
                        mabog.passwordreset = dr.Item(11).ToString

                        mlista.Add(mabog)

                    Next
                End If

                Return mlista

            Catch ex As Exception
                Throw ex
            End Try
        End Function

    End Class
End Namespace

